package top.bbman.boot.redis.bean;

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import top.bbman.boot.logger.LogConstant;
import top.bbman.boot.redis.constant.PeaRedisBeanName;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * String operations
 *
 * @author 祥霸
 * @version 1.0
 */
@Component(PeaRedisBeanName.DIY_STRING_REDIS)
public class PeaStringRedis {

    @PostConstruct
    private void init() {
        LogConstant.bbManRedis.info("init string redis");
    }

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    public void set(String key, String val) {
        stringRedisTemplate.opsForValue().set(key, val);
    }

    public String get(String key) {
        return stringRedisTemplate.opsForValue().get(key);
    }
}
